﻿using Anley.DomainDrivenDesign.Contract.DependencyInjection;

namespace Anley.DomainDrivenDesign.Contract.Helper;

/// <summary>
/// 加密帮助接口
/// </summary>
public interface IEncryptionHelper
    : ISingletonAutoInject
{
    #region 国密算法

    /// <summary>
    /// SM2服务端加密
    /// </summary>
    /// <param name="plainText">明文</param>
    /// <param name="publicKey">公钥</param>
    string SM2ServerEncrypt(
        string plainText,
        string? publicKey = null);

    /// <summary>
    /// SM2客户端加密
    /// </summary>
    /// <param name="plainText"></param>
    /// <param name="publicKey"></param>
    string SM2ClientEncrypt(
        string plainText,
        string? publicKey = null);

    /// <summary>
    /// SM2服务端解密
    /// </summary>
    /// <param name="cipherText">密文</param>
    /// <param name="privateKey">私钥</param>
    string SM2ServerDecrypt(
        string cipherText,
        string? privateKey = null);

    /// <summary>
    /// SM2服务端签名
    /// </summary>
    /// <param name="plainText">明文</param>
    /// <param name="privateKey">私钥</param>
    string SM2ServerSignature(
        string plainText,
        string? privateKey = null);

    /// <summary>
    /// SM2服务端验签
    /// </summary>
    /// <param name="plainText">明文</param>
    /// <param name="signText">签名</param>
    /// <param name="publicKey">公钥</param>
    bool SM2ServerVerifySignature(
        string plainText,
        string signText,
        string? publicKey = null);

    /// <summary>
    /// SM2客户端验签
    /// </summary>
    /// <param name="plainText"></param>
    /// <param name="signText"></param>
    /// <param name="publicKey"></param>
    bool SM2ClientVerifySignature(
        string plainText,
        string signText,
        string? publicKey = null);

    /// <summary>
    /// SM3签名
    /// </summary>
    /// <param name="plainText">明文</param>
    string SM3Signature(
        string plainText);

    /// <summary>
    /// SM3签名
    /// </summary>
    /// <param name="plainText">明文</param>
    /// <param name="secretKey">密钥</param>
    string HMacSM3Signature(
        string plainText,
        string? secretKey = null);

    /// <summary>
    /// SM4加密
    /// </summary>
    /// <param name="plainText">明文</param>
    /// <param name="secretKey">密钥</param>
    string SM4Encrypt(
        string plainText,
        string? secretKey = null);

    /// <summary>
    /// SM4解密
    /// </summary>
    /// <param name="cipherText">密文</param>
    /// <param name="secretKey">密钥</param>
    string SM4Decrypt(
        string cipherText,
        string? secretKey = null);

    #endregion

    #region 加密算法

    /// <summary>
    /// SHA1加密
    /// </summary>
    /// <param name="plainText"></param>
    /// <returns></returns>
    string SHA1Encrypt(string plainText);

    #endregion
}